package com.nursing.controller.Elder;

import com.nursing.bean.Family;
import com.nursing.model.Result;
import com.nursing.service.FamilyService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/elderFamily")
public class ElderFamilyController {
    private final FamilyService familyService;

    public ElderFamilyController(FamilyService familyService) {
        this.familyService = familyService;
    }

    @GetMapping("/getFamilyByElder")
    public Result<List<Family>> getFamilyByElder(@RequestParam Integer elderId) {
        return Result.success(familyService.getFamilyByElder(elderId));
    }

    @DeleteMapping("/deleteFamily")
    public Result<Family> deleteFamily(@RequestParam Integer id) {
        familyService.delete(id);
        return Result.success("删除成功");
    }

    @PostMapping("/addFamily")
    public Result<Family> addFamily(@RequestBody Family family) {
        familyService.add(family);
        return Result.success("添加成功");
    }
}
